home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / wgt_tp1.zip / WGT06.PAS < prev    next >
Pascal/Delphi Source File  |  1992-07-05  |  4KB  |  99 lines

  1. {**************************************************************************
  2.                           WordUp Graphics Toolkit
  3.                                 Demo File
  4.                      Loading blocks and Simple Text Output
  5.  
  6.  
  7.  This file demonstrates LOAD, RESIZE and FREE _block commands. The user
  8.  positions the mouse on the screen and hits the left button. A loaded image
  9.  is then resized to fit within the defined area of the screen. The right
  10.  hand button ends the program.
  11.  **************************************************************************}
  12.  
  13. USES Graph,WGT,CRT;
  14.  
  15. VAR
  16.    x, y, button, oldx, oldy, grDriver, grMode : INTEGER;
  17.    installed : BOOLEAN;
  18.    ch : CHAR;
  19.    image : POINTER;             { Pointer to our loaded graphics block }
  20.    p : PALETTE;                 { This is a type specific to WGT }
  21.  
  22. BEGIN
  23.      CLRSCR;
  24.      WRITELN('Press right mouse button to end the program.');
  25.      DELAY(6000);
  26.  
  27.      { Initialize graphics (see demo file #1) }
  28.      grDriver := INSTALLUSERDRIVER('VGA256',NIL);
  29.      grMode := 0;
  30.      INITGRAPH(grDriver,grMode,'c:\tp\bgi');
  31.  
  32.      _ClearDevice(0);
  33.  
  34.      Load_Palette('c:\tp\wgt\face.pal',p);   { Load palette and set it }
  35.      Set_Palette_Block(0,255,p);
  36.  
  37.      image:=NIL;                             { Pointer must be initialized }
  38.      Load_Block('c:\tp\wgt\face.blk',image); { Load from file into memory  }
  39.  
  40.      {*******************************************************************}
  41.      { After running the program once, remove the REMARK brackets from   }
  42.      { the next line and notice how the image is flipped.                }
  43.      {Flip_Block( image, vertical );                                     }
  44.  
  45.  
  46.      mouse_init(installed, button);          { Initialize mouse }
  47.      mouse_on;                               { Display cursor   }
  48.      oldx:=-1;            { Set previous coordinates so display is updated }
  49.      oldy:=-1;
  50.  
  51.      REPEAT
  52.            mouse(x,y,button);     { Read in x,y and button status }
  53.  
  54.            IF ( x <> oldx ) OR ( y <> oldy ) THEN BEGIN     { If moved }
  55.  
  56.               mouse_off;                { Disable cursor while updating }
  57.  
  58.               _setcolor(0);             { Erase old lines with black }
  59.               _line(oldx,0,oldx,oldy);
  60.               _line(0,oldy,oldx,oldy);
  61.  
  62.               _setcolor(30);            { Draw new lines with white }
  63.               _line(x,0,x,y);
  64.               _line(0,y,x,y);
  65.  
  66.               oldx:=x;                  { Set new coordinates }
  67.               oldy:=y;
  68.               mouse_on;                 { Display cursor again }
  69.            END;
  70.  
  71.            { Now check to see if the left button is pressed }
  72.  
  73.            IF ( button=1 ) AND ( x > 0 ) AND ( y > 0 ) THEN BEGIN
  74.  
  75.               mouse_off;                 { Disable cursor }
  76.  
  77.               resize_block(0,0,x-1,y-1,image);   { Draw face within area }
  78.  
  79.               _textcolor(50);                    { Set text color }
  80.               texttransparent(mask);           { Do not display background }
  81.               _outtextxy(100,190,'Press any key.');
  82.  
  83.               REPEAT UNTIL KEYPRESSED;        { Input a key }
  84.               ch:=READKEY;
  85.  
  86.               _cleardevice(0);            { Clear screen and re-initialize }
  87.               oldx:=-1;
  88.               oldy:=-1;
  89.               mouse_on;
  90.            END;
  91.  
  92.      UNTIL button=2;       { Right hand button ends the program }
  93.  
  94.      Free_Block( image );  { Deallocate the memory used by the block }
  95.  
  96.      { Now close the graphics system }
  97.  
  98.      CLOSEGRAPH;
  99. END.